<template>
  <div>
    <el-card>
      <div slot="header">
        <div class="categroy">
          <span>销售额类别占比</span>
          <el-radio-group v-model="value">
            <el-radio-button label="全部渠道"></el-radio-button>
            <el-radio-button label="线上"></el-radio-button>
            <el-radio-button label="门店"></el-radio-button>
          </el-radio-group>
        </div>
      </div>
      <div class="charts" ref="charts"></div>
    </el-card>
  </div>
</template>

<script>
import * as echarts from "echarts";
export default {
  name: "",
  data() {
    return {
      value: "全部渠道",
    };
  },
  mounted() {
    let pie = echarts.init(this.$refs.charts);
    pie.setOption({
        title:{
            text:'视频',
            subtext:1230,
            left:'center',
            top:'center'
        },
      tooltip: {
        trigger: "item",
      },
   
      series: [
        {
          name: "Access From",
          type: "pie",
          radius: ["40%", "70%"],
          avoidLabelOverlap: false,
          itemStyle: {
            borderRadius: 10,
            borderColor: "#fff",
            borderWidth: 2,
          },
          label: {
            show: true,
            position: "outside",
          },
        
          labelLine: {
            show: true,
          },
          data: [
            { value: 1048, name: "Search Engine" },
            { value: 735, name: "Direct" },
            { value: 580, name: "Email" },
            { value: 484, name: "Union Ads" },
            { value: 300, name: "Video Ads" },
          ],
        },
      ],
    });
    pie.on('mouseover', (params)=> {
    const {name,value} = params.data
    pie.setOption({
        title:{
            text:name,
            subtext:value
        }
    })
});
  },
  
};
</script>

<style scoped>
.categroy {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 10px;
}
.charts {
  width: 100%;
  height: 300px;
}
</style>
